//package com.wxy.demo.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
//
//import java.util.concurrent.Executor;
//import java.util.concurrent.ThreadPoolExecutor;
//
///**
// * <p>
// *
// * </p>
// *
// * @author e-Xiaoyuan.Wang
// * @since 2022/9/30 16:18
// */
//@EnableAsync
//@Configuration
//public class TaskExecutorConfig {
//
//    /**
//     * 创建异步调用的线程池
//     * @return
//     */
//    @Bean("taskExecutor")
//    public Executor taskExecutor() {
//        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//        executor.setCorePoolSize(1);// 初始化线程数
//        executor.setMaxPoolSize(2);// 最大活跃线程数
//        executor.setQueueCapacity(1);// 如果初始化线程用完，则会加入到线程队列，如果队列用完，则会开启新线程，当活跃线程数大于最大数，则阻塞
//        executor.setKeepAliveSeconds(2);// 线程最大空闲时间
//        executor.setThreadNamePrefix("taskExecutor-");
//        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//        return executor;
//    }
//}